<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="24" class="custom-title-box">
        <div class="custom-info-title">
          {{getTitleByName(nameOfPermission)}}列表查询
          <el-button link @click="delFav()" style="margin-bottom: 5px;" v-if="userFavorites?.length > 0">
            <svg-icon icon-class="stars" color="#E6A23C" />
          </el-button>
          <el-button link @click="addFav()" style="margin-bottom: 5px;" v-else>
            <svg-icon icon-class="star" />
          </el-button>
        </div>
        <div>
          <el-button v-waves type="success" icon="Search" @click="handleFilter">
            查询
          </el-button>
          <el-button icon="Refresh" @click="handleResetQuery">
            重置
          </el-button>
        </div>
      </el-col>
    </el-row>
    <div class="filter-container">
      <el-form :inline="true" ref="listQuery" :model="listQuery" class="demo-form-inline">
        <!--
        <el-form-item prop="treasuryType" label="支付令类型">
          <el-radio-group v-model="listQuery.treasuryType">
            <el-radio-button label="" key="">全部</el-radio-button>
            <el-radio-button v-for="(item,index) in getEnumList('ExpenditureTreasuryType')" :label="item.key" :key="index">{{item.value}}</el-radio-button>
          </el-radio-group>
        </el-form-item>
        -->
        <el-form-item prop="treasuryCode" label="支付令编码">
          <InputTagDialog v-model="listQuery.treasuryCode" placeholder="支付令编码" title="填写支付令编码" />
        </el-form-item>
        <el-form-item prop="treasuryName" label="支付令名称">
          <el-input v-model="listQuery.treasuryName" placeholder="支付令名称" @keyup.enter="handleFilter" />
        </el-form-item>
        <el-form-item label="申请日期">
          <el-date-picker v-model="listQuery.applicationDateRange"
                          value-format="YYYY-MM-DD HH:mm:ss"
                          type="datetimerange"
                          range-separator="-"
                          start-placeholder="申请日期开始"
                          end-placeholder="申请日期结束" />
        </el-form-item>
        <el-form-item prop="applicationOrganizationId" label="申请人部门">
          <Organization v-model="listQuery.applicationOrganizationId" keyName="id" keyShow="organizationName" placeholder="申请人部门" title="部门查询" :disabled="useUserStore().organization.organizationType !== '1'" />
        </el-form-item>
        <el-form-item prop="applicationUserId" label="申请人用户">
          <User v-model="listQuery.applicationUserId" keyName="id" keyShow="name" placeholder="用户" title="用户查询" :disabled="useUserStore().organization.organizationType !== '1'" />
        </el-form-item>
        <!--
        <el-form-item prop="amount" label="申请金额">
          <el-input v-model="listQuery.amount" placeholder="申请金额" @keyup.enter="handleFilter" />
        </el-form-item>
        -->
        <el-form-item prop="state" label="状态">
          <el-radio-group v-model="listQuery.state">
            <el-radio-button label="" key="">全部</el-radio-button>
            <el-radio-button v-for="(item,index) in getEnumList('ExpenditureTreasuryState')" :label="item.key" :key="index">{{item.value}}</el-radio-button>
          </el-radio-group>
        </el-form-item>
        <el-form-item prop="fundDealings" label="资金往来对象类别">
          <el-input v-model="listQuery.fundDealings" placeholder="资金往来对象类别" @keyup.enter="handleFilter" />
        </el-form-item>
        <el-form-item prop="fundType" label="资金类型">
          <el-input v-model="listQuery.fundType" placeholder="资金类型" @keyup.enter="handleFilter" />
        </el-form-item>
        <el-form-item prop="innerOrg" label="单位内部机构">
          <el-input v-model="listQuery.innerOrg" placeholder="单位内部机构" @keyup.enter="handleFilter" />
        </el-form-item>
        <el-form-item prop="payType" label="支付方式(国库)">
          <el-select v-model="listQuery.payType" class="m-2" placeholder="请选择" clearable filterable>
            <el-option v-for="item in getDictList('ExpenditurePay')" :key="item.key" :label="`${item.key} - ${item.value}`" :value="item.key" />
          </el-select>
        </el-form-item>
        <el-form-item prop="settleType" label="结算方式">
          <el-select v-model="listQuery.settleType" class="m-2" placeholder="请选择" clearable filterable>
            <el-option v-for="item in getDictList('ExpenditureSettlement')" :key="item.key" :label="`${item.key} - ${item.value}`" :value="item.key" />
          </el-select>
        </el-form-item>
        <el-form-item prop="businessType" label="支付业务类型">
          <el-input v-model="listQuery.businessType" placeholder="支付业务类型" @keyup.enter="handleFilter" />
        </el-form-item>
        <el-form-item prop="exchequer" label="国库支付令号">
          <el-input v-model="listQuery.exchequer" placeholder="国库支付令号" @keyup.enter="handleFilter" />
        </el-form-item>
        <!--
        <el-form-item prop="exchequerMessage" label="国库支付令消息">
          <el-input v-model="listQuery.exchequerMessage" placeholder="国库支付令消息" @keyup.enter="handleFilter" />
        </el-form-item>
        <el-form-item prop="summary" label="摘要">
          <el-input v-model="listQuery.summary" placeholder="摘要" @keyup.enter="handleFilter" />
        </el-form-item>
        -->
      </el-form>
    </div>
    <el-row :gutter="20">
      <el-col :span="24" class="custom-title-box">
        <div class="custom-info-title">列表详情</div>
        <div>
          <el-button v-show="checkAuthByCode('')" type="primary" icon="Download" @click="handleExport">
            导出
          </el-button>
          <el-button type="primary" icon="Edit" :disabled="!checkAuthByCode('')" @click="handleAdd">
            新增
          </el-button>
        </div>
      </el-col>
    </el-row>
    <el-divider class="el-divider--horizontal-margin" />
    <el-table v-loading="listLoading"
              :key="tableKey"
              :data="list"
              :row-style="{height: '0'}"
              :cell-style="{padding: '0'}"
              border
              fit
              highlight-current-row
              tooltip-effect="dark"
              @sort-change="handleSortChange"
              @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="39px" />
      <el-table-column align="center" type="index" label="序号" width="60px" />
      <el-table-column v-if="isDebug" align="center" label="ID" prop="id" width="60px" sortable show-overflow-tooltip />
      <!--
      <el-table-column align="center" label="支付令类型" prop="treasuryType" min-width="130px" sortable show-overflow-tooltip>
        <template v-slot="{row}">
          <EnumTag :enum-list="getEnumList('ExpenditureTreasuryType')" :enum-key="row.treasuryType" />
        </template>
      </el-table-column>
      -->
      <el-table-column align="center" label="支付令编码" prop="treasuryCode" min-width="130px" sortable show-overflow-tooltip>
        <template v-slot="{row}"><CodeTag :code="row.treasuryCode" /></template>
      </el-table-column>
      <el-table-column align="center" label="支付令名称" prop="treasuryName" min-width="130px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.treasuryName }}</template>
      </el-table-column>
      <el-table-column align="center" label="申请日期" prop="applicationDate" min-width="120px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.applicationDate?.substring(0, 10) }}</template>
      </el-table-column>
      <el-table-column align="center" label="申请人部门" prop="applicationOrganizationId" min-width="180px" sortable show-overflow-tooltip>
        <template v-slot="{row}">
          <LabelTag :foreignList="organizationList" :foreignIds="row.applicationOrganizationId" :foreignLabel="'organizationName'" />
        </template>
      </el-table-column>
      <el-table-column align="center" label="申请人用户" prop="applicationUserId" min-width="180px" sortable show-overflow-tooltip>
        <template v-slot="{row}">
          <LabelTag :foreignList="userList" :foreignIds="row.applicationUserId" :foreignLabel="'name'" />
        </template>
      </el-table-column>
      <el-table-column align="center" label="申请金额" prop="amount" min-width="120px" sortable show-overflow-tooltip>
        <template v-slot="{row}"><MoneyTag :money="row.amount" /></template>
      </el-table-column>
      <el-table-column align="center" label="状态" prop="state" min-width="100px" sortable show-overflow-tooltip>
        <template v-slot="{row}">
          <EnumTag :enum-list="getEnumList('ExpenditureTreasuryState')" :enum-key="row.state" />
        </template>
      </el-table-column>
      <el-table-column align="center" label="资金往来对象类别" prop="fundDealings" min-width="205px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.fundDealings }}</template>
      </el-table-column>
      <el-table-column align="center" label="资金类型" prop="fundType" min-width="120px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.fundType }}</template>
      </el-table-column>
      <el-table-column align="center" label="单位内部机构" prop="innerOrg" min-width="155px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.innerOrg }}</template>
      </el-table-column>
      <el-table-column align="center" label="支付方式(国库)" prop="payType" min-width="205px" sortable show-overflow-tooltip>
        <template v-slot="{row}">
          <DictTag :dict-list="getDictList('ExpenditurePay')" :dict-key="row.payType" />
        </template>
      </el-table-column>
      <el-table-column align="center" label="结算方式" prop="settleType" min-width="160px" sortable show-overflow-tooltip>
        <template v-slot="{row}">
          <DictTag :dict-list="getDictList('ExpenditureSettlement')" :dict-key="row.settleType" />
        </template>
      </el-table-column>
      <el-table-column align="center" label="支付业务类型" prop="businessType" min-width="155px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.businessType }}</template>
      </el-table-column>
      <el-table-column align="center" label="国库支付令号" prop="exchequer" min-width="155px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.exchequer }}</template>
      </el-table-column>
      <el-table-column align="center" label="国库支付令消息" prop="exchequerMessage" min-width="180px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.exchequerMessage }}</template>
      </el-table-column>
      <el-table-column align="center" label="摘要" prop="summary" min-width="80px" sortable show-overflow-tooltip>
        <template v-slot="{row}">{{ row.summary }}</template>
      </el-table-column>
      <el-table-column align="center" label="备注" prop="remark" min-width="200px" show-overflow-tooltip />
      <el-table-column align="center" label="创建时间" width="180px" prop="createTime" sortable show-overflow-tooltip>
        <template v-slot="{row}"><DateTag :timestamp="row.createTime" /></template>
      </el-table-column>
      <el-table-column align="center" label="最后修改时间" width="180px" prop="updateTime" sortable show-overflow-tooltip>
        <template v-slot="{row}"><DateTag :timestamp="row.updateTime" /></template>
      </el-table-column>
      <el-table-column align="center" label="操作" width="200px" fixed="right">
        <template v-slot="{row}">
          <el-button type="primary" link @click="handleView(row)">查看</el-button>
          <el-button v-show="checkAuthByCode('')" type="primary" link
                     @click="handleEdit(row)" v-if="row.state === '0'">编辑</el-button>
          <el-popconfirm confirm-button-text="确定"
                         cancel-button-text="取消"
                         :icon="WarningFilled"
                         icon-color="#626AEF"
                         title="您确定删除么？"
                         @confirm="handleDelete(row)"
                         v-if="checkAuthByCode('') && row.state === '0'">
            <template #reference>
              <el-button type="danger" link>删除</el-button>
            </template>
          </el-popconfirm>
          <el-button v-show="checkAuthByCode('')" type="primary" link
                     @click="handleSync(row)" v-if="row.state === '0'">同步到国库</el-button>
          <el-button v-show="checkAuthByCode('')" type="primary" link
                     @click="handleExchequer(row)" v-if="row.state === '1'">录入结果</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-model:total="total" v-model:page="listQuery.pageNum" v-model:limit="listQuery.pageSize" @pagination="getList" />
    <!-- <el-dialog v-model="dialogVisible" :title="dialogTypeTitle" width="70%" top="2vh">
      <el-form class="my-form" ref="obj" :model="obj" :rules="rules" label-position="right" :disabled="dialogType === 'view'" label-width="auto">
        <el-form-item v-show="isDebug" label="ID">
          <text>{{ obj.id }}</text>
        </el-form-item>
        <el-form-item label="支付令类型" prop="treasuryType">
          <el-radio-group v-model="obj.treasuryType">
            <el-radio-button v-for="(item,index) in getEnumList('ExpenditureTreasuryType')" :label="item.key" :key="index">{{item.value}}</el-radio-button>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="支付令编码" prop="treasuryCode">
          <el-input v-model="obj.treasuryCode" placeholder="请输入支付令编码，最多输入100个字符" />
        </el-form-item>
        <el-form-item label="支付令名称" prop="treasuryName">
          <el-input v-model="obj.treasuryName" placeholder="请输入支付令名称，最多输入200个字符" />
        </el-form-item>
        <el-form-item label="申请日期" prop="applicationDate">
          <el-date-picker v-model="obj.applicationDate" placeholder="请输入申请日期" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" />
        </el-form-item>
        <el-form-item label="申请人部门ID" prop="applicationOrganizationId">
          <el-input v-model="obj.applicationOrganizationId" type="number" placeholder="请输入申请人部门ID" />
        </el-form-item>
        <el-form-item label="申请人用户ID" prop="applicationUserId">
          <el-input v-model="obj.applicationUserId" type="number" placeholder="请输入申请人用户ID" />
        </el-form-item>
        <el-form-item label="申请金额" prop="amount">
          <el-input-number v-model="obj.amount" placeholder="请输入申请金额" />
        </el-form-item>
        <el-form-item label="状态" prop="state">
          <el-radio-group v-model="obj.state">
            <el-radio-button v-for="(item,index) in getEnumList('ExpenditureTreasuryState')" :label="item.key" :key="index">{{item.value}}</el-radio-button>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="资金往来对象类别" prop="fundDealings">
          <el-input v-model="obj.fundDealings" placeholder="请输入资金往来对象类别，最多输入20个字符" />
        </el-form-item>
        <el-form-item label="资金类型" prop="fundType">
          <el-input v-model="obj.fundType" placeholder="请输入资金类型，最多输入20个字符" />
        </el-form-item>
        <el-form-item label="单位内部机构" prop="innerOrg">
          <el-input v-model="obj.innerOrg" placeholder="请输入单位内部机构，最多输入200个字符" />
        </el-form-item>
        <el-form-item label="支付方式(国库)" prop="payType">
          <el-input v-model="obj.payType" placeholder="请输入支付方式(国库)，最多输入20个字符" />
        </el-form-item>
        <el-form-item label="结算方式" prop="settleType">
          <el-input v-model="obj.settleType" placeholder="请输入结算方式，最多输入20个字符" />
        </el-form-item>
        <el-form-item label="支付业务类型" prop="businessType">
          <el-input v-model="obj.businessType" placeholder="请输入支付业务类型，最多输入20个字符" />
        </el-form-item>
        <el-form-item label="国库支付令号" prop="exchequer">
          <el-input v-model="obj.exchequer" placeholder="请输入国库支付令号，最多输入300个字符" />
        </el-form-item>
        <el-form-item label="国库支付令消息" prop="exchequerMessage">
          <el-input v-model="obj.exchequerMessage" placeholder="请输入国库支付令消息，最多输入500个字符" />
        </el-form-item>
        <el-form-item label="摘要" prop="summary">
          <el-input v-model="obj.summary" :autosize="{ minRows: 2, maxRows: 5}" type="textarea" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="obj.remark" :autosize="{ minRows: 2, maxRows: 5}" type="textarea" />
        </el-form-item>
        <el-form-item label="创建时间">
          <text>{{ obj.createTime || '自动生成' }}</text>
        </el-form-item>
        <el-form-item label="最后修改时间">
          <text>{{ obj.updateTime || '自动生成' }}</text>
        </el-form-item>
        <el-form-item v-show="isDebug" label="数据版本">
          <text>{{ obj.version }}</text>
        </el-form-item>
      </el-form>
      <div style="text-align:right;">
        <el-button type="info" icon="Close" @click="dialogVisible=false">关闭</el-button>
        <el-button type="primary" icon="Check" v-show="dialogType !== 'view'" @click="doConfirm('obj')">确定</el-button>
      </div>
    </el-dialog> -->
  </div>
</template>

<script>
import baseConfig from '@/mixins/baseConfig'
import {doGet, doPost, doPut, doDelete, doGetDownload} from '@/config/http'
import {alertErrorMsg, customValidator, getListPageSize, notifySuccess} from '@/config/common'
import InputTagDialog from "@/components/InputTag/inputTagDialog.vue";
import User from "@/views/components/base/selectUser.vue";
import SvgIcon from "@/components/SvgIcon/index.vue";
import Organization from "@/views/components/base/selectOrganization.vue";
import useUserStore from "@/store/modules/user";
import {getUserId} from "@/config/cookie";
import initListStore from '@/store/modules/initList'

const emptyObj = {
  treasuryType: null, // 支付令类型
  treasuryCode: null, // 支付令编码
  treasuryName: null, // 支付令名称
  applicationDate: null, // 申请日期
  applicationOrganizationId: null, // 申请人部门ID
  applicationUserId: null, // 申请人用户ID
  amount: null, // 申请金额
  state: null, // 状态
  fundDealings: null, // 资金往来对象类别
  fundType: null, // 资金类型
  innerOrg: null, // 单位内部机构
  payType: null, // 支付方式(国库)
  settleType: null, // 结算方式
  businessType: null, // 支付业务类型
  exchequer: null, // 国库支付令号
  exchequerMessage: null, // 国库支付令消息
  summary: null, // 摘要
  remark: null, // 备注
  id: null,
  createBy: null,
  createTime: null,
  updateBy: null,
  updateTime: null,
  deleted: null,
  version: null,
}

export default {
  name: 'expenditureTreasury_nocache',
  components: {Organization, SvgIcon, User, InputTagDialog},
  mixins: [baseConfig],
  data() {
    return {
      svc: 'icims-api',
      obj: Object.assign({}, emptyObj),
      routes: [],
      dialogVisible: false,
      dialogType: 'add',
      dialogTypeTitle: '新增',
      checkStrictly: false,
      defaultProps: {
        children: 'children',
        label: 'title'
      },
      tableKey: 0,
      list: null,
      total: 0,
      listLoading: false,
      listQuery: {
        pageNum: 1,
        pageSize: 10,
        sortField: 'id',
        sortType: 'desc',
        treasuryType: null,
        treasuryCode: null,
        treasuryName: null,
        applicationDateStart: null,
        applicationDateEnd: null,
        applicationDateRange: [],//
        applicationOrganizationId: useUserStore().organization.organizationType !== '1' ? useUserStore().organization.id : '',
        applicationUserId: useUserStore().organization.organizationType !== '1' ? getUserId() : '',
        amount: null,
        state: null,
        fundDealings: null,
        fundType: null,
        innerOrg: null,
        payType: null,
        settleType: null,
        businessType: null,
        exchequer: null,
        exchequerMessage: null,
        summary: null,
        createTimeStart: null,
        createTimeEnd: null,
        updateTimeStart: null,
        updateTimeEnd: null,
      },
      selectionList: [],
      dialogFormVisible: false,
      dialogStatus: '',
      rules: {
        treasuryType: [{ required: true, validator: customValidator, min: 1, max: 20, label: '支付令类型', trigger: ['blur', 'change'] }],
        treasuryCode: [{ required: false, validator: customValidator, min: 0, max: 100, label: '支付令编码', trigger: ['blur', 'change'] }],
        treasuryName: [{ required: true, validator: customValidator, min: 1, max: 200, label: '支付令名称', trigger: ['blur', 'change'] }],
        applicationDate: [{ required: false, validator: customValidator, min: 0, max: 20, label: '申请日期', trigger: ['blur', 'change'] }],
        applicationOrganizationId: [{ required: false, validator: customValidator, min: 0, max: 20, label: '申请人部门ID', trigger: ['blur', 'change'] }],
        applicationUserId: [{ required: false, validator: customValidator, min: 0, max: 20, label: '申请人用户ID', trigger: ['blur', 'change'] }],
        amount: [{ required: false, validator: customValidator, min: 0, max: 13, label: '申请金额', trigger: ['blur', 'change'] }],
        state: [{ required: false, validator: customValidator, min: 0, max: 20, label: '状态', trigger: ['blur', 'change'] }],
        fundDealings: [{ required: true, validator: customValidator, min: 1, max: 20, label: '资金往来对象类别', trigger: ['blur', 'change'] }],
        fundType: [{ required: false, validator: customValidator, min: 0, max: 20, label: '资金类型', trigger: ['blur', 'change'] }],
        innerOrg: [{ required: true, validator: customValidator, min: 1, max: 200, label: '单位内部机构', trigger: ['blur', 'change'] }],
        payType: [{ required: true, validator: customValidator, min: 1, max: 20, label: '支付方式(国库)', trigger: ['blur', 'change'] }],
        settleType: [{ required: true, validator: customValidator, min: 1, max: 20, label: '结算方式', trigger: ['blur', 'change'] }],
        businessType: [{ required: true, validator: customValidator, min: 1, max: 20, label: '支付业务类型', trigger: ['blur', 'change'] }],
        exchequer: [{ required: false, validator: customValidator, min: 0, max: 300, label: '国库支付令号', trigger: ['blur', 'change'] }],
        exchequerMessage: [{ required: false, validator: customValidator, min: 0, max: 500, label: '国库支付令消息', trigger: ['blur', 'change'] }],
        summary: [{ required: false, validator: customValidator, min: 0, max: 1000, label: '摘要', trigger: ['blur', 'change'] }],
        remark: [{ required: false, validator: customValidator, min: 0, max: 0, label: '备注', trigger: ['blur', 'change'] }],
      },
      userList: initListStore().userList,
      organizationList: initListStore().organizationList,
    }
  },
  computed: {
    routesData() {
      return this.routes
    },
  },
  created() {
    this.nameOfPermission = 'expenditureTreasury'
    this.getFavorite(this.nameOfPermission)?.then(res => this.userFavorites = res)
    this.getList()
    // this.initList()
  },
  methods: {
    useUserStore,
    // async initList() {
    //   let p1 = doGet(this.svc, '/user/page', {pageSize: getListPageSize()}, false)
    //   let p2 = doGet(this.svc, '/organization/page', {pageSize: getListPageSize()}, false)
    //   let resArray = await Promise.all([p1, p2])
    //   this.userList = resArray[0]['records']
    //   this.organizationList = resArray[1]['records']
    // },
    getList() {
      this.listLoading = true
      this.listQuery.applicationDateStart = ''
      this.listQuery.applicationDateEnd = ''
      if (this.listQuery.applicationDateRange) {
        this.listQuery.applicationDateStart = this.listQuery.applicationDateRange[0]
        this.listQuery.applicationDateEnd = this.listQuery.applicationDateRange[1]
      }
      doGet(this.svc, '/expenditure-treasury/page', this.listQuery).then(res => {
        this.listLoading = false
        this.list = res['records']
        this.total = parseInt(res['total'])
      }).catch(e => {
        console.error(e)
        this.listLoading = false
      })
    },
    handleResetQuery() {
      this.resetForm("listQuery")
      this.listQuery.applicationDateStart = ''
      this.listQuery.applicationDateEnd = ''
      this.listQuery.applicationDateRange = []
    },
    handleFilter() {
      this.listQuery.pageNum = 1
      this.getList()
    },
    handleModifyStatus(row, status) {
      this.$message({
        message: '操作Success',
        type: 'success'
      })
      row.status = status
    },
    handleSelectionChange(data) {
      this.selectionList = data
    },
    handleSortChange(data) {
      const { prop, order } = data
      this.listQuery.sortField = prop
      this.listQuery.sortType = order === 'ascending' ? 'asc' : 'desc'
      this.handleFilter()
    },
    handleEdit(row) {
      // this.dialogType = 'edit'
      // this.dialogTypeTitle = '编辑'
      // this.dialogVisible = true
      // this.checkStrictly = true
      // this.obj = Object.assign({}, row)
      this.goTargetByName('expenditureTreasuryEdit', {id: row.id, oper: 'edit'})
    },
    handleView(row) {
      // this.dialogType = 'view'
      // this.dialogTypeTitle = '详情'
      // this.dialogVisible = true
      // this.checkStrictly = false
      // this.obj = Object.assign({}, row)
      this.goTargetByName('expenditureTreasuryEdit', {id: row.id, oper: 'view'})
    },
    handleAdd() {
      // this.dialogType = 'add'
      // this.dialogTypeTitle = '新增'
      // this.dialogVisible = true
      // this.checkStrictly = true
      // this.obj = Object.assign({}, emptyObj)
      this.goTargetByName('expenditureTreasuryEdit', {oper: 'add'})
    },
    handleExport() {
      doGetDownload(this.svc, '/expenditure-treasury/export', this.listQuery)
    },
    handleDelete(row) {
      doDelete(this.svc, '/expenditure-treasury/' + row.id, {}).then(() => {
        notifySuccess('操作成功')
        this.getList()
        this.dialogVisible = false
      })
    },
    async doConfirm(formName) {
      let v = await this.$refs[formName].validate().catch((err)=>{return err})
      if (v !== true) {
        alertErrorMsg('表单验证不通过，请检查数据。')
        return
      }
      if (this.dialogType === 'edit') {
        doPut(this.svc, '/expenditure-treasury/modify', this.obj).then(() => {
          notifySuccess('操作成功')
          this.getList()
          this.dialogVisible = false
        })
      } else if (this.dialogType === 'add') {
        doPost(this.svc, '/expenditure-treasury/add', this.obj).then(() => {
          notifySuccess('操作成功')
          this.getList()
          this.dialogVisible = false
        })
      }
    },
    handleSync(row) {
      this.$confirm('您确定要同步到国库么？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(_ => {
        row.state = '1'
        doPut(this.svc, '/expenditure-treasury/modify', row).then(() => {
          notifySuccess('操作成功')
          this.getList()
          this.dialogVisible = false
        })
      })
    },
    handleExchequer(row) {
      this.goTargetByName('expenditureTreasuryEdit', {id: row.id, oper: 'exchequer'})
    },
  }
}
</script>
